package Stack;

import LinkList.LinkList;
import LinkList.ListNode;

public class Test {
    public static void main(String[] args) {
        test1();
        test2();
        test3();
    }
    public static void test1() {
        System.out.println("==============test1==============");
        Stack stack=new Stack();
        stack.push(1);
        stack.push(2);
        stack.push(3);
        stack.push(4);
        int val= stack.pop();
        System.out.println(val);
        System.out.println(stack.peek());
        System.out.println("==============test2===============");
    }

    public static void test2() {
        //使用栈的特点倒着遍历链表
        java.util.Stack<ListNode> stack=new java.util.Stack<>();
        LinkList linkList=new LinkList();
        linkList.addLast(1);
        linkList.addLast(2);
        linkList.addLast(3);
        linkList.addLast(4);
        ListNode cur=linkList.head;
        while(cur!=null) {
            stack.push(cur);
            cur=cur.next;
        }
        while(!stack.empty()) {
            cur=stack.pop();
            System.out.print(cur.data+" ");
        }
        System.out.println();
        System.out.println("==============test3==============");
    }

    public static void test3() {
        MinStack minStack=new MinStack();
        minStack.push(-1);
        minStack.push(0);
        minStack.push(-3);
        System.out.println(minStack.getMin());
        minStack.pop();
        System.out.println(minStack.top());
        minStack.pop();
        System.out.println(minStack.getMin());
    }
}
